<template>
    <div>
        <vue-tinymce :placeholder="placeholder" v-model="editContent" :setting="setting" />
    </div>
</template>
<script>
export default {
    name:'MyTinymce',
    mounted(){
    },
    props:{
        content:{
            type:String,
            default:''
        },
        placeholder:{
            type:String,
            default:'请输入'
        },
        height:{
            type:Number,
            default:200
        },
    },
    mounted(){
        if(this.content){
            this.editContent = this.content;
        }
    },
    data(){
        return{
            //因为子组件无法改变父组件的数据，用中间值来接收一下
            editContent:'',
            //富文本的配置
            setting: {
                menubar: false,
                elementpath: false,
                toolbar: "undo redo | fullscreen | formatselect alignleft aligncenter alignright alignjustify | numlist bullist  | fontselect fontsizeselect forecolor backcolor | bold italic underline strikethrough | indent outdent | superscript subscript | removeformat | kityformula-editor",
                // toolbar_drawer: "sliding",
                quickbars_selection_toolbar: "removeformat | bold italic underline strikethrough | fontsizeselect forecolor backcolor",
                plugins: "lists fullscreen quickbars kityformula-editor",
                language: 'zh_CN',
                height: this.height,
                resize:false,
	        }
        }        
    },
    //子组件需要改变父组件的值的时候
    watch:{
        editContent:{
            handler(newVal,oldVal){
                this.$emit('update:content',newVal)
                console.log(this.content+'新的值',newVal);
            }
        }
    }
}
</script>

<style>

</style>